package com.cskaoyan.bean;

import com.cskaoyan.bean.po.admin.role.MarketRolePermission;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.lang.reflect.Field;

/**
 * @author MoJunXiang
 * @since 2022/09/09 21:46
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class MarketRolePermissionColumns {
    private Boolean id = false;
    private Boolean role_id = false;
    private Boolean permission_detail_id = false;
    private Boolean permission_detail_id_str = false;

    public void addColumn(String fieldName) throws NoSuchFieldException, IllegalAccessException {
        Class<? extends MarketRolePermissionColumns> columnsClazz = this.getClass();
        Field field = columnsClazz.getDeclaredField(fieldName);
        field.setAccessible(true);
        field.set(this, true);
    }

    public void addAllColumns() throws IllegalAccessException {
        Class<? extends MarketRolePermissionColumns> columnsClazz = this.getClass();
        Field[] fields = columnsClazz.getFields();
        for (Field field : fields) {
            field.setAccessible(true);
            field.set(this, true);
        }
    }
}
